package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.helper.widget.Carousel;
import androidx.constraintlayout.helper.widget.Carousel.Adapter;

public class MainActivity16 extends AppCompatActivity {

    private Carousel mCarousel;

    private int[] images = {
        R.drawable.caodi_shangdegou003,
        R.drawable.goucelia001,
        R.drawable.yaoshu_zhigo008,
        R.drawable.yaowan_jugou021,
        R.drawable.guanlanya008
    };

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity16.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main16 );

        initView();
    }

    private void initView() {

        mCarousel = (Carousel) findViewById( R.id.carousel );
        mCarousel.setAdapter( new Adapter() {
            @Override
            public int count() {

                return images.length;
            }

            @Override
            public void populate( View view, int index ) {

                ((ImageView) view).setImageResource( images[index] );
            }

            @Override
            public void onNewItem( int index ) {

            }
        } );
    }
}